package site.lianwu.mybatis.plus.query.model;

import site.lianwu.mybatis.plus.query.define.Condition;
import site.lianwu.mybatis.plus.query.define.Logic;
import site.lianwu.mybatis.plus.query.define.Validation;
import site.lianwu.mybatis.plus.query.processor.QueryClassProcessor;
import site.lianwu.mybatis.plus.query.processor.QueryFieldProcessor;

import java.lang.reflect.Field;

/**
 * 预备查询语句
 * <br>
 * 该类封装了查询语句的定义信息，包括值验证、分组、（分组内的）逻辑操作、列名以及查询条件
 *
 * @author LianWu
 * @see QueryClassProcessor#extract(Class, boolean)
 * @see QueryFieldProcessor#extract(Field)
 */
public class PreparedQueryStatement {

    /**
     * 值验证
     */
    private final Validation validation;

    /**
     * 所属分组
     */
    private final String group;

    /**
     * 逻辑操作符，定义该查询条件在分组内与其他条件的逻辑连接关系
     */
    private final Logic logic;

    /**
     * （数据表中的）列名
     */
    private final String column;

    /**
     * 查询条件
     */
    private final Condition condition;

    public PreparedQueryStatement(Validation validation, String group, Logic logic, String column, Condition condition) {
        this.validation = validation;
        this.group = group;
        this.logic = logic;
        this.column = column;
        this.condition = condition;
    }

    public Validation getValidation() {
        return validation;
    }

    public String getGroup() {
        return group;
    }

    public Logic getLogic() {
        return logic;
    }

    public String getColumn() {
        return column;
    }

    public Condition getCondition() {
        return condition;
    }

}
